package com.xunk.equipment.api;

import com.xunk.common.core.constant.ServiceNameConstants;
import com.xunk.common.core.domain.ControlDeviceParam;
import com.xunk.common.core.web.domain.AjaxResult;
import com.xunk.equipment.api.domain.MessageNotificationDO;
import com.xunk.equipment.api.factory.RemoteEquipmentFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @ProjectName: xunk
 * @Package: com.xunk.equipment.api
 * @ClassName: RemoteEquControlService
 * @Author: dongxiaoxin
 * @Description: 设备控制
 * @Date: 2021/4/6 15:07
 * @Version: 1.0
 */
@FeignClient(contextId = "remoteEquipmentService", value = ServiceNameConstants.EQUIPMENT_SERVICE, fallbackFactory = RemoteEquipmentFallbackFactory.class)
public interface RemoteEquipmentService {

    /**
     * 场景端批量控制设备
     *
     * @param list 设备参数列表
     * @return
     */
    @PostMapping(value = "/batch/control", headers = {"secret=1234"})
    AjaxResult controlDevice(List<ControlDeviceParam> list);

    @PostMapping("/batch/control")
    AjaxResult controlDevice(@RequestHeader(name = "sceneKey") String sceneKey, List<ControlDeviceParam> list);

    @GetMapping("/ruying/delete")
    AjaxResult deleteRuyingDevice(@RequestParam(value = "deviceSns") String deviceSns, @RequestParam(value = "deptId") Long deptId);

    @PostMapping("/message/save")
    AjaxResult insertMessageNotification(List<MessageNotificationDO> messages);

    /**
     * 根据设备号查询设备信息
     *
     * @param deviceSn
     * @return
     */
    @GetMapping("/info")
    AjaxResult info(@RequestParam("deviceSn") String deviceSn);

    /**
     * 获取某个家庭下的所有设备列表
     *
     * @param homeId
     * @param deviceSource
     * @return
     */
    @GetMapping("list")
    AjaxResult list(@RequestParam("homeId") Long homeId,
                    @RequestParam(value = "deviceSource", required = false, defaultValue = "0") Integer deviceSource);
}
